package unimelb.discussiontracker.twitter.data.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "TweetUser")
@NamedQueries(value = {
        @NamedQuery(name = "User.FindByName", query = "SELECT user FROM UserEntity user WHERE user.name = :name"),
        @NamedQuery(name = "User.FindByTag", query = "SELECT DISTINCT(tweet.owner) FROM TweetEntity tweet JOIN tweet.hashTags tag JOIN tweet.owner WHERE tag.id = :tagId") })
public class UserEntity {
    @Id
    @Column(name = "Id")
    private long id;

    @Column(name = "Name")
    private String name;

    @OneToMany(mappedBy = "owner")
    private List<TweetEntity> ownTweets;

    @OneToMany(mappedBy = "user")
    private List<TweetUserAssociation> mentionedTweets;

    @OneToMany(mappedBy = "user")
    private List<UserRanking> rankings;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<TweetEntity> getOwnTweets() {
        return ownTweets;
    }

    public void setOwnTweets(List<TweetEntity> ownTweets) {
        this.ownTweets = ownTweets;
    }

    public List<TweetUserAssociation> getMentionedTweets() {
        return mentionedTweets;
    }

    public void setMentionedTweets(List<TweetUserAssociation> mentionedTweets) {
        this.mentionedTweets = mentionedTweets;
    }

}
